package cmd

import (
	"fmt"
	"gitee.com/cdsailyj/go-vpn/global"
	"gitee.com/cdsailyj/go-vpn/service"
)

type CmdGroup struct {
	TestCmd
	AptCmd
	TableCmd
	HealthCmd
	RobotCmd
	VpnWebRtcService
}

var CmdGroupApp = &CmdGroup{}

var officeServiceApp = &service.OfficeService{}

var cmdMapper = map[string]func(){
	"test.func1":       CmdGroupApp.TestCmd.Func1,
	"test.delete-face": CmdGroupApp.TestCmd.DeleteFace,
	"test.sync-face":   CmdGroupApp.TestCmd.SyncFace,
	"test.search-face": CmdGroupApp.TestCmd.SearchFace,
	"test.identity":    CmdGroupApp.TestCmd.Identity,
	"test.upload":      CmdGroupApp.TestCmd.UploadImage,
	"test.add-face":    CmdGroupApp.TestCmd.AddFace,
	"test.download":    CmdGroupApp.TestCmd.Download,
	"test.sign-id":     CmdGroupApp.TestCmd.SyncId,
	"test.secret":      CmdGroupApp.TestCmd.Secret,
	"test.refresh":     CmdGroupApp.TestCmd.Refresh,
	"test.ref":         CmdGroupApp.TestCmd.Ref,

	"apt.fix":      CmdGroupApp.AptCmd.Fix,
	"apt.business": CmdGroupApp.AptCmd.BusinessDepartment,
	"apt.sm4test":  CmdGroupApp.AptCmd.Sm4Test,
	"apt.sm4":      CmdGroupApp.AptCmd.Sm4,
	"apt.depart":   CmdGroupApp.AptCmd.Depart,
	"apt.project":  CmdGroupApp.AptCmd.Project,
	"apt.export":   CmdGroupApp.AptCmd.Export,
	"apt.office":   CmdGroupApp.AptCmd.Office,
	"apt.clock":    CmdGroupApp.AptCmd.Clock,

	"table.export": CmdGroupApp.TableCmd.Export,

	"health.project":       CmdGroupApp.HealthCmd.Project,
	"health.match":         CmdGroupApp.HealthCmd.Match,
	"health.cancer":        CmdGroupApp.HealthCmd.Cancer,
	"health.slow-breath":   CmdGroupApp.HealthCmd.SlowBreath,
	"health.cta1":          CmdGroupApp.HealthCmd.CoronaryCta,
	"health.cta2":          CmdGroupApp.HealthCmd.HeadCta,
	"health.dead":          CmdGroupApp.HealthCmd.Dead,
	"health.dead-time":     CmdGroupApp.HealthCmd.DeadTime,
	"health.second-office": CmdGroupApp.HealthCmd.SecondOffice,
	"health.health-stats":  CmdGroupApp.HealthCmd.HealthStats,

	"robot.screenshot": CmdGroupApp.RobotCmd.Screenshot,

	"vpn.clientB": CmdGroupApp.VpnWebRtcService.VpnClientB,
	"vpn.turn":    CmdGroupApp.VpnWebRtcService.Turn,
}

func StartCmd() {
	if len(global.Cmd) == 0 {
		return
	}

	f, ok := cmdMapper[global.Cmd]

	if !ok {
		fmt.Println("cmd 没有对应的方法:" + global.Cmd)
		return
	}
	f()
}
